package com.liuya.common.listener;

import com.liuya.common.SpringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

//@WebFilter
//@WebInitParam()
//@WebServlet
@WebListener
public class WebAppContextListener implements ServletContextListener {
	
	private final static Logger logger = LoggerFactory.getLogger(WebAppContextListener.class);

	@Override
	public void contextDestroyed(ServletContextEvent event) {
		try{
			 
		} catch (Exception e) {
			e.printStackTrace();
			logger.info("销毁WebSocket实例失败===" + e);
		}
	}

	@Override
	public void contextInitialized(ServletContextEvent event) {
		ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
		SpringUtils.WEB_APP_CONTEXT = context;
	}
}
